/**
 * 初始化医嘱项详情对话框
 */
var CdcOrdmastInfoDlg = {
    validateFields: {
    	xcode: {
            validators: {
                notEmpty: {
                    message: '索引码不能为空'
                }
            }
        },
    	code: {
            validators: {
                notEmpty: {
                    message: '代码不能为空'
                }
            }
        },
    	description: {
            validators: {
                notEmpty: {
                    message: '描述不能为空'
                }
            }
        },
    	busOrderTypeId: {
            validators: {
                notEmpty: {
                    message: '类型不能为空'
                }
            }
        },
    	dataId: {
            validators: {
                notEmpty: {
                    message: '业务数据类型不能为空'
                }
            }
        },
    	isActive: {
            validators: {
                notEmpty: {
                    message: '是否有效不能为空'
                }
            }
        },
    }
};


/**
 * 关闭此对话框
 */
CdcOrdmastInfoDlg.close = function() {
    parent.layer.close(parent.layer.getFrameIndex(window.name)); //先得到当前iframe层的索引,再执行关闭   
}

/**
 * 验证数据是否为空
 */
CdcOrdmastInfoDlg.validate = function () {
    $('#cdcOrdmastInfoForm').data("bootstrapValidator").resetForm();
    $('#cdcOrdmastInfoForm').bootstrapValidator('validate');
    return $("#cdcOrdmastInfoForm").data('bootstrapValidator').isValid();
}

/**
 * 提交新增
 */
CdcOrdmastInfoDlg.addSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcOrdmastInfoForm',Sys.backendPath + "/cdc/cdcordmast/add",function(res) {
        Sys.success(res.message);
    	window.parent.CdcOrdmast.table.refresh();
        CdcOrdmastInfoDlg.close();
    });
}

/**
 * 提交修改
 */
CdcOrdmastInfoDlg.editSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcOrdmastInfoForm',Sys.backendPath + "/cdc/cdcordmast/update",function(res) {
        Sys.success(res.message);
    	window.parent.CdcOrdmast.table.refresh();
        CdcOrdmastInfoDlg.close();
    });
}

$(function() {
	Sys.initValidator("cdcOrdmastInfoForm", CdcOrdmastInfoDlg.validateFields);
    $("#dataId").combobox("disable");
    $("#dataId").combobox('setValue', window.parent.CdcOrdmast.sysDataId);
});
